package com.a01_2021.thousandstimes.saas.service.impl;

import com.a01_2021.thousandstimes.saas.entity.Post;
import com.a01_2021.thousandstimes.saas.mapper.PostMapper;
import com.a01_2021.thousandstimes.saas.service.PostService;
import com.a01_2021.thousandstimes.utils.AjaxResponse;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: thousandstimes
 * @description:
 * @author: FRQ
 * @create: 2021-03-30 17:24
 **/
@Service
public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements PostService {

    @Autowired
    private PostMapper postMapper;

    @Override
    public AjaxResponse getPost() {
        List<Post> posts = postMapper.selectList(null);
        return AjaxResponse.success(posts);
    }

    /**
     * 用于检查是否为有效职位
     *
     * @param postId 职位Id
     * @return 是否为有效职位
     */
    @DS("master")
    public boolean isPost(long postId) {
        return postMapper.selectById(postId) != null;
    }
}
